<template>
  <!--  组件的结构-->
  <div class="school">
    <h2>学校名称：{{ name}}</h2>
    <h2>学校地址：{{ address }}</h2>
    <button @click="sendSchoolName">点我发送学校名称</button>
  </div>
</template>

<script>
// 组件交互相关的代码(数据、方法等等)
import pubsub from 'pubsub-js'

export default {
  name: 'School',
  data() {
    return {
      name: '尚硅谷',
      address: '北京昌平'
    }
  },
  methods:{
    sendSchoolName(){
      pubsub.publish('hello',this.name)
    }
  }
}
</script>

<style scoped>
/*组件的样式*/
.school {
  background-color: orange;
  padding: 5px;
  margin-top: 30px;
}
</style>